"use strict";
$(window).on("load", function () {
    setTimeout(function () {
        $(".page-loader").fadeOut();
    }, 300);
}), $(document).ready(function () {
    if (localStorage.getItem("data-ma-theme")) {
        var themeLoc = localStorage.getItem("data-ma-theme");
        $("body").attr("data-ma-theme", themeLoc);
        var themeClass = ".bg-" + themeLoc;
        var $theme_switched = $(".theme-switch .btn" + themeClass),
            $theme_not = $theme_switched.siblings(".btn");
        $theme_switched.addClass("active");
        $theme_not.removeClass("active");
        $theme_switched.find("input:radio").attr("checked");
        $theme_not.find("input:radio").removeAttr("checked");
    }
    $("body").on("change", ".theme-switch input:radio", function () {
        var a = $(this).val();
        $("body").attr("data-ma-theme", a);
        localStorage.setItem("data-ma-theme", a);
    }), $("body").on("focus", ".search__text", function () {
        $(this).closest(".search").addClass("search--focus")
    }), $("body").on("blur", ".search__text", function () {
        $(this).val(""), $(this).closest(".search").removeClass("search--focus")
    }), $("body").on("click", ".navigation__sub > a", function (a) {
        a.preventDefault(), $(this).parent().toggleClass("navigation__sub--toggled"), $(this).next("ul").slideToggle(250)
    }), $(".form-group--float")[0] && ($(".form-group--float").each(function () {
        0 == !$(this).find(".form-control").val().length && $(this).find(".form-control").addClass("form-control--active")
    }), $("body").on("blur", ".form-group--float .form-control", function () {
        0 == $(this).val().length ? $(this).removeClass("form-control--active") : $(this).addClass("form-control--active")
    }))
}), $(document).ready(function () {
    function a(a) {
        a.requestFullscreen ? a.requestFullscreen() : a.mozRequestFullScreen ? a.mozRequestFullScreen() : a.webkitRequestFullscreen ? a.webkitRequestFullscreen() : a.msRequestFullscreen && a.msRequestFullscreen()
    }

    $("body").on("click", "[data-ma-action]", function (b) {
        b.preventDefault();
        var c = $(this), d = c.data("ma-action"), e = "";
        switch (d) {
            case"search-open":
                $(".search").addClass("search--toggled");
                break;
            case"search-close":
                $(".search").removeClass("search--toggled");
                break;
            case"aside-open":
                e = c.data("ma-target"), c.addClass("toggled"), $(e).addClass("toggled"), $(".content, .header").append('<div class="ma-backdrop" data-ma-action="aside-close" data-ma-target=' + e + " />");
                break;
            case"aside-close":
                e = c.data("ma-target"), $('[data-ma-action="aside-open"], ' + e).removeClass("toggled"), $(".content, .header").find(".ma-backdrop").remove();
                break;
            case"fullscreen":
                a(document.documentElement);
                break;
            case"print":
                window.print();
                break;
            case"clear-localstorage":
                localStorage.clear();
                break;
            case"login-switch":
                e = c.data("ma-target"), $(".login__block").removeClass("active"), $(e).addClass("active");
                break;
            case"notifications-clear":
                b.stopPropagation();
                var f = $(".top-nav__notifications .listview__item"), g = f.length, h = 0;
                c.fadeOut(), f.each(function () {
                    var a = $(this);
                    setTimeout(function () {
                        a.addClass("animated fadeOutRight")
                    }, h += 150)
                }), setTimeout(function () {
                    f.remove(), $(".top-nav__notifications").addClass("top-nav__notifications--cleared")
                }, 180 * g);
                break;
            case"toolbar-search-open":
                $(this).closest(".toolbar").find(".toolbar__search").fadeIn(200), $(this).closest(".toolbar").find(".toolbar__search input").focus();
                break;
            case"toolbar-search-close":
                $(this).closest(".toolbar").find(".toolbar__search input").val(""), $(this).closest(".toolbar").find(".toolbar__search").fadeOut(200)
        }
    })
});

function dataTables_init() {
        if ($("#data-table")[0]) {
            $("#data-table").DataTable({
                searching: true,
                ordering: true,
                autoWidth: !1,
                responsive: !0,
                lengthMenu: [[15, 30, 45, -1], ["显示15项", "显示30项", "显示45项", "显示所有"]],
                language: {
                    searchPlaceholder: "搜索...",
                    sZeroRecords: "没有匹配项...",
                    sInfo: "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                    sInfoEmpty: "显示第 0 至 0 项结果，共 0 项",
                    sInfoFiltered: "（总共 _MAX_ 项）"
                },
                sDom: '<"dataTables__top"lfB>rt<"dataTables__bottom"ip><"clear">',
                buttons: [{extend: "excelHtml5", title: "Export Data"}, {
                    extend: "csvHtml5",
                    title: "Export Data"
                }, {extend: "print", title: "Material Admin"}],
                initComplete: function (a, b) {
                    $(this).closest(".dataTables_wrapper").find(".dataTables__top").prepend('<div class="dataTables_buttons hidden-sm-down actions"><span class="actions__item zmdi zmdi-print" data-table-action="print" /><span class="actions__item zmdi zmdi-fullscreen" data-table-action="fullscreen" /><div class="dropdown actions__item"><i data-toggle="dropdown" class="zmdi zmdi-download" /><ul class="dropdown-menu dropdown-menu-right"><a href="" class="dropdown-item" data-table-action="excel">Excel (.xlsx)</a><a href="" class="dropdown-item" data-table-action="csv">CSV (.csv)</a></ul></div></div>')
                }
            }), $(".dataTables_filter input[type=search]").focus(function () {
                $(this).closest(".dataTables_filter").addClass("dataTables_filter--toggled")
            }), $(".dataTables_filter input[type=search]").blur(function () {
                $(this).closest(".dataTables_filter").removeClass("dataTables_filter--toggled")
            }), $("body").on("click", "[data-table-action]", function (a) {
                a.preventDefault();
                var b = $(this).data("table-action");
                if ("excel" === b && $(this).closest(".dataTables_wrapper").find(".buttons-excel").trigger("click"), "csv" === b && $(this).closest(".dataTables_wrapper").find(".buttons-csv").trigger("click"), "print" === b && $(this).closest(".dataTables_wrapper").find(".buttons-print").trigger("click"), "fullscreen" === b) {
                    var c = $(this).closest(".card");
                    c.hasClass("card--fullscreen") ? (c.removeClass("card--fullscreen"), $("body").removeClass("data-table-toggled")) : (c.addClass("card--fullscreen"), $("body").addClass("data-table-toggled"))
                }
            })
        }
        $(".scrollbar-inner")[0] && $(".scrollbar-inner").scrollbar().scrollLock();
}

dataTables_init();